package com.lagou.edu.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping
public class LoginController {
    @RequestMapping("/login")
    String login(HttpSession session, String username, String password) {
        // 登录了直接返回
        if (session.getAttribute("user") != null) {
            return "redirect:/resume/findAll";
        }


        if ("admin".equals(username) || "admin".equals(password)) {
            // 登录成功
            session.setAttribute("user", username);
            return "redirect:/resume/findAll";
        } else {
            // 登录失败
            return "login.jsp";
        }
    }
}
